Manages the nodes available in the component. More...
Public Member Functions | |
Node * | create () |
Node * | createOrRetrieve (const nkMemory::StringView &name) |
Node * | get (const nkMemory::StringView &name) const |
Node * | getByIndex (unsigned int index) const |
void | rename (const nkMemory::StringView ¤tName, const nkMemory::StringView &newName) |
void | erase (const nkMemory::StringView &name) |
Manages the nodes available in the component.
At all times, the manager is responsible for memory returned. External code should never free it.
The manager is the entry point when starting a graph. By creating a node through createOrRetrieve, a local root can be obtained.
To construct a graph, it is either possible to instanciate a new node through the Manager and add it to the graph, or call graph managing functions on an existing node.
Node* nkGraphics::NodeManager::create | ( | ) |
Creates a node.
This version of the function will use an internal counter to create names shaped like "Node_0", "Node_1". The counter gets incremented as the function gets called.
Node* nkGraphics::NodeManager::createOrRetrieve | ( | const nkMemory::StringView & | name | ) |
Creates if unavailable, or retrieves if available, a node.
name | The name of the node to retrieve. |
Node* nkGraphics::NodeManager::get | ( | const nkMemory::StringView & | name | ) | const |
Retrieves an existing node.
name | The name of the node wanted. |
Node* nkGraphics::NodeManager::getByIndex | ( | unsigned int | index | ) | const |
Retrieves a node given an index. Note that as the internal memory is changed, an index can map to different nodes over different calls. Mainly used to loop over all nodes in one go.
index | The index of the node to retrieve. |
void nkGraphics::NodeManager::rename | ( | const nkMemory::StringView & | currentName, |
const nkMemory::StringView & | newName | ||
) |
Renames a node, changing both its name and the way it is accessed through the manager.
currentName | The name of the node to rename. |
newName | The name to attach. |
void nkGraphics::NodeManager::erase | ( | const nkMemory::StringView & | name | ) |
Erases and frees the memory of a node.
name | The name of the node to erase. |